package com.wxf.listener;

import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageListener;

import java.io.UnsupportedEncodingException;

public class RoutingListener02 implements MessageListener {


    @Override
    public void onMessage(Message message) {
        try {
            String msg = new String(message.getBody(),"utf-8");
            System.out.printf("监听器：%s，交换机：%s， 队列：%s， 路由key：%s， 消息：%s\n",
                    "RoutingListener02",
                    message.getMessageProperties().getReceivedExchange(),
                    message.getMessageProperties().getConsumerQueue(),
                    message.getMessageProperties().getReceivedRoutingKey(),
                    msg);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
    }
}
